/*!
 * \file Exception.h
 * \brief Defines the Exception class for CLAP.
 */

#ifndef _CLAP_EXCEPTION_H_
#define _CLAP_EXCEPTION_H_

#include <Common/Exception.h>
#include <Common/Types.h>
#include <CLAP/Types.h>

using namespace libCLAP;

namespace libCLAP
{
   namespace CLAP
   {
      /*!
       * \class Exception
       * \brief Exception handling for CLAP
       *
       * These CLAP :: Exceptions are specifically targeted towards CLAP.
       * The main error for this class is located at _CLAPError. Since this
       * class is inherited from Common :: Exception, it also contains the
       * usual _What variable and _Error.
       */
      class Exception :
         public Common :: Exception
      {
         public :

            /*!
             * \brief Constructor
             *
             * Constructor for the CLAP :: Exception class. This constructor
             * takes in an CLAP :: Error and fills in the _Error variable
             * with ecustom. _CLAPError is the error set by this class.
             * _CLAPError is set to error in this constructor, and a
             * corresponding ErrorMessage is generated by calling this
             * classes Message function.
             *
             * \param error An CLAP :: Error that gets set as the _CLAPError
             *              variable.
             */
            Exception ( const CLAP :: Error error );

            /*!
             * \brief Constructor
             *
             * Constructor for the CLAP :: Exception class. This constructor
             * takes in an CLAP :: Error and fills in the _Error variable
             * with ecustom. _CLAPError is the error set by this class.
             * _CLAPError is set to error in this constructor, and
             * _ErrorMessage is set to messgage by calling the Common ::
             * Exception constructor with just message.
             *
             * \param error An CLAP :: Error that gets set as the _CLAPError
             *              variable.
             * \param message An CLAP :: ErrorMessage that gets set as the
             *                _ErrorMessage variable.
             */
            Exception ( const CLAP :: Error error,
                        const Common :: ErrorMessage message );

            /*!
             * \brief Constructor
             *
             * Constructor for the CLAP :: Exception class. This constructor
             * takes in an Common :: ErrorMessage and sets _ErrorMessage
             * equal to message, by calling the Common :: Exception
             * constructor with just the message. The _CLAPError variable is
             * set to enotspec.
             *
             * \param message An CLAP :: ErrorMessage that gets set as the
             *                _ErrorMessage variable.
             */
            Exception ( const Common :: ErrorMessage message );

            /*!
             * \brief Constructor
             *
             * Constructor for the CLAP :: Exception class. This constructor
             * takes in an Common :: Error and _Error equal to error by
             * calling the Common :: Exception with just error as the
             * parameter. The _CLAPError variable is set to enotspec. This is
             * mainly used by the CLAP functions to catch a socket error and
             * convert it to an CLAP :: Exception.
             *
             * \param error A Common :: Error that gets set as the _Error
             *              variable.
             */
            Exception ( const Common :: Error error );

            /*!
             * \brief Copy Constructor
             *
             * Constructor for the CLAP :: Exception class. This
             * constructor creates a copy of an already existing CLAP ::
             * Exception object.
             *
             * \param copy A CLAP :: Exception object that is to be
             *             copied.
             */
            Exception ( const CLAP :: Exception & copy );

            /*!
             * \brief Destructor
             *
             * Destructor for the CLAP :: Exception class.
             */
            virtual ~Exception ( void ) throw ();

            /*!
             * \brief Variable Manipulator
             *
             * Standard function to access the class variable.
             */
            virtual const CLAP :: Error & CLAPError ( void ) const;

         protected :

            /*!
             * \brief Variable Manipulator
             *
             * Standard function to access the class variable.
             */
            virtual const CLAP :: Error & CLAPError
                                    ( const CLAP :: Error & variable );

            /*!
             * \brief Message function
             *
             * \param error An CLAP :: Error type to convert
             *
             * This function takes error and gives back a string with the error
             * message. It is a helper function used mainly to fill _What when
             * no custom message is specified.
             */
            static CLAP :: ErrorMessage Message ( const CLAP :: Error & error );

            CLAP :: Error        _CLAPError; /*!< This is the CLAP error code
                                                  that caused the exception.*/
      };
   }
}
#endif
